/**
 * Created by zhangqingxi on 2017-04-01.
 */

$(function () {

    initDept();
    initSolidWasteType();
    initSolidWaste(0);
    resetCombogrid('#hazardousWasteCodeId');
    resetCombobox('#deviceId');
    initShape();
    initGenerationSource();

    //保存表单
    initSaveClick(modelPath+'add.shtml');
    //提交表单到工作流
    $('#btn_submit').on('click',function () {

        var confirmIndex=layer.confirm('是否确定提交审批？', function () {
            layer.close(confirmIndex);
            var isValid = $('#submit_form').form('validate');
            if (!isValid) {
                layer.msg("请正确填写表单");
                return
            }
            /***
             * 选择处理人
             */
            WindowManager.openLayer({
                type: 2,
                title: '选择下一环节处理人',
                area: ['370px', '180px'],
                content: ROOT_PATH + '/workflow/flowManagement/toFlowNextUserSelectPage.shtml',
                data:{id:'ff',name:'我是名称'},
                callBack:function(data){//窗口关闭后的回调函数
                    //得到选择的人员
                    if(data==null||data===""){
                        layer.alert("请选择处理人!");
                        return false;
                    }
                    $('#submit_form').form('submit', {
                        url: modelPath+'addSubmit.shtml',
                        onSubmit: function (param) {
                            param['nextUserId']=data;
                            param['auditState']=1;
                        },
                        success: function (result) {
                            var data = $.parseJSON(result);
                            successCallback(data)
                        }
                    });
                }
            });
        });

    });

});